package unit6;

import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.swing.Timer;

public class InnerClassTest {
	public static void main(String[] args) {
		
	}
	class TalkingClock{
		@SuppressWarnings("unused")
		private int interval;
		private boolean beep;
		public TalkingClock(int interval, boolean beep) {
			this.interval = interval;
			this.beep = beep;
		}
		public class TimerPrinter implements ActionListener{
			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				Date now=new Date();
				SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd  hh:mm");
				String d=sdf.format(now);
				System.out.println("At the tone , the time is "+d);
				if(beep)
					Toolkit.getDefaultToolkit().beep();
			}
			
		}
		public void start(){
			ActionListener listener=new TimerPrinter();
			Timer t=new Timer(10000, listener);
			t.start();
		}
	}
}
